package com.ll.admin.action;

import com.ll.admin.service.IMemberService;
import org.apache.shiro.SecurityUtils;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

//密码修改
@Controller
@RequestMapping("pages/front/password/*")
public class PasswordAction {
    @Autowired
    IMemberService memberService ;

    //ajax验证当前密码是否正确
    @ResponseBody
    @RequestMapping("checkPassword")
    public boolean checkPassword(String password) {
        return SecurityUtils.getSubject().getSession().getAttribute("password").equals(password) ? true : false ;
    }
    //修改密码
    @RequestMapping("editPassword")
    public String editPassword(String new_password) {
        if(new_password != null){
            memberService.doEditPassword(SecurityUtils.getSubject().getSession().getAttribute("mid").toString(),new_password) ;
        }
        return "redirect:/logout.shiro" ;
    }
}
